﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using HA.Data;

namespace HA.ModFlow.Controls.Windows.DataOperation
{
    /// <summary>
    /// winKrigingOptions.xaml 的交互逻辑
    /// </summary>
    public partial class winKrigingOptions : Window
    {
        public winKrigingOptions(Project proj,KrigingOption krig)
        {
            InitializeComponent();
            this._krigingOption = (KrigingOption)krig.Clone();
        }

        Project _proj = new Project();

        public Project Proj
        {
            get { return _proj; }
            set { _proj = value; }
        }

        private KrigingOption _krigingOption = new KrigingOption();

        public KrigingOption KrigingOption
        {
            get { return _krigingOption; }
            set { _krigingOption = value; }
        }

      


        private void btnDrift_Click(object sender, RoutedEventArgs e)
        {
            winDriftCoefficients win = new winDriftCoefficients();
            win.ShowDialog();
        }

        private void btnSearchOption_Click(object sender, RoutedEventArgs e)
        {
            winSearchOptions win = new winSearchOptions(this .KrigingOption.SearchOption);
            if (win.ShowDialog().Value)
            {
                this.KrigingOption.SearchOption = win.SearchOption;
            }
        }

        private void btnSearchEllipsoid_Click(object sender, RoutedEventArgs e)
        {
            winSearchEllipsoid win = new winSearchEllipsoid(this .KrigingOption.Ellipsoid);
            if (win.ShowDialog().Value)
            {
                this.KrigingOption.Ellipsoid = win.SearchEllipsoid;
            }
        }

        private void btnEditVariog_Click(object sender, RoutedEventArgs e)
        {
            winVariogramEditor win = new winVariogramEditor(this .Proj);
            win.ArryVariogram.Add((HAMath.ModelVariogram) this.KrigingOption.ModelVariogram.Clone ());
            if (win.ShowDialog().Value)
            {
                if (win.ArryVariogram.Count > 0)
                {
                    this.KrigingOption.ModelVariogram = win.ArryVariogram[0];
                }
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            switch ( this._krigingOption.KrigType)
            {
                case HAMath.KrigingType.Ordinary:
                    this.rbtnOrdinary.IsChecked = true;
                    this.btnDrift.IsEnabled = false;
                    break;
                case HAMath.KrigingType.Simple:
                    this.btnDrift.IsEnabled = true;
                    this.rbtnSimple.IsChecked = true;
                    break;
            }
        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (this.rbtnOrdinary.IsChecked.Value)
            {
                this._krigingOption.KrigType = HAMath.KrigingType.Ordinary;
            }
            if (this.rbtnSimple.IsChecked.Value)
            {
                this._krigingOption.KrigType = HAMath.KrigingType.Simple;
            }
            this.DialogResult = true;
            this.Close();
        }

        private void btnCancal_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
